<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<link rel="stylesheet" href="../../static/assets/css/zpui.css"/>
<link rel="stylesheet" href="../../static/assets/css/all.css"/>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>


    <title> 会员管理 </title>
    <style>
        .weui-navbar__item.weui-bar__item--on:after {
            width: 40px;
            height: 4px;
            background-color: #f65236;
        }

        .weui-navbar__item.weui-bar__item--on {
            background: transparent;
        }
        .affirm{
            width:40px;
            height:30px;
            float: right;
            position:relative;
            margin-top:-30px;
        }
    </style>
</head>
<body>
<div class="page">
    <div class="page-hd">
        <div class="header bor-1px-b">
    <div class="header-left">
        <a href="javascript:history.go(-1)" class="left-arrow"></a>
    </div>
    <div class="header-title">会员管理</div>
    <div class="header-right">
        <a href="#"></a>
    </div>
</div>
    </div>

    <div class="page-bd">
        <!-- 页面内容-->
        <div class="member_top">
            <div class="search-bar">
                <form action="#">
                    <input type="text" placeholder="请输入用户ID或者手机号" id="seek">
                </form>
                <div class="affirm" onclick="seek()"></div>
            </div>
            <div class="card-flex text-white" style="background: transparent;padding-bottom: 0.8rem;">
                <div class="flex_item">
                    <div class="fs36 fw600 week">0</div>
                    <div class="fs24 mt20">本周新增人数</div>
                </div>
                <div class="flex_item">
                    <div class="fs36 fw600 month">0</div>
                    <div class="fs24 mt20">本月新增人数</div>
                </div>
            </div>
        </div>
        <!-- 容器 -->
        <div class="weui-tab" style="margin-top: -0.2rem;">
            <div class="weui-navbar" style="background: transparent;">
                <a class="weui-navbar__item weui-bar__item--on" data-type='2' onclick="selected(2)" href="#tab1">
                    VIP
                </a>
                <a class="weui-navbar__item" data-type='1' onclick="selected(1)" href="#tab1">
                    访客
                </a>
            </div>
            <div class="weui-tab__bd">
                <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
                    <!--<div class="fs24 text-muted mt30 tc">已经到底啦~</div>-->
                </div>
            </div>
        </div>

    </div>

</div>

<script src="../../static/assets/js/lib/jquery-2.1.4.js"></script>
<script src="../../static/assets/js/jquery-weui.min.js"></script>
 <script src="../../static/js/jquery/jquery.cookie.js"></script>
<script src="../../static/assets/js/lib/fastclick.js"></script>
<script src="../../static/assets/js/page.js"></script>
<script>
    let html = '';
    let data = "";
    let page = 2;
    let length = 0;
    let time = 1;
    
          share()
     function  share(){
    /***用户点击分享到微信圈后加载接口接口*******/
        var url=window.location.href;
        console.log("url:"+url);
            $.ajax({
		    url: "/api/mp/wxconfig",
		    type: "post",
		    data:{shareUrl:url},
		    headers:{ token: $.cookie('code')},
		    dataType: "json",
		    success: function(data){
		         configData = {
                    debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                    appId: data.data.appid, // 必填，公众号的唯一标识
                    timestamp: data.data.timestamp, // 必填，生成签名的时间戳
                    nonceStr: data.data.nonceStr, // 必填，生成签名的随机串
                    signature: data.data.signature,// 必填，签名，见附录1
                    jsApiList : ['hideOptionMenu']
                    // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
               };
               
               //step2:注入配置信息
               wx.config(configData);
               //step3:通过ready接口处理成功验证
               wx.ready(function () {
                   // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
//                 alert("执行ready方法");
//                 wx.checkJsApi({
//                      jsApiList: ['chooseImage'] // 需要检测的JS接口列表，所有JS接口列表见附录2,
//                      success: function(res) {
//                      // 以键值对的形式返回，可用的api值true，不可用为false
//                      // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
//                      }
//                 });
                   //接口1:获取网络类型
                    wx.getNetworkType({
                        success: function (res) {
                          oldNet = res.networkType; // 返回网络类型2g，3g，4g，wifi
//                        alert("网络类型"+ oldNet);
                        }
                     });
                   //禁用右上角菜单按钮
                   wx.hideOptionMenu();
		    })
		    },
		    error: function() {
// 			    _alert('ajax request failed!!!!');
			    return;
		    } 
        })

	    
	    
	    }
    $(function() {
        FastClick.attach(document.body);
        requestAjax({'userLevelId':2});
        var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
        var nScrollTop = 0;   //滚动到的当前位置
        var nDivHight = $("#tab1").height();
        $("#tab1").scroll(function(){

            nScrollHight = $(this)[0].scrollHeight;
            nScrollTop = $(this)[0].scrollTop;
            if(nScrollTop + nDivHight >= nScrollHight)
            {
                time = 2;
                if(length < 10){
                    return false;
                }
                data['page'] = page;
                requestAjax(data);
            }
        });
        
        
      
    });
    function selected(e){
        html = '';
        time = 1
        requestAjax({'userLevelId':e});
    }
    $('form').on('submit', function(e){
        html = '';
        time = 3
        requestAjax({'userNameOrMobile':$('#seek').val(),userLevelId:$('.weui-bar__item--on').attr('data-type')});
    });
    function seek(){
        html = '';
        time = 4
        requestAjax({'userNameOrMobile':$('#seek').val(),userLevelId:$('.weui-bar__item--on').attr('data-type')});
    }
    function requestAjax(e){
        data = e;
        $.ajax({
            type:"get",
            url:"/api/mp/getPromoterList",
            data:e,
            headers: { 'token': $.cookie('code') },
                        dataType: 'json',
            success:function(res){
                console.log(res)

                for (key in res.data.promoterList) {
                    let  money =  5000000 + Number(res.data.promoterList[key].userId)
                    let mobile = res.data.promoterList[key].mobile ? res.data.promoterList[key].mobile : "";
                    let img = res.data.promoterList[key].avatar ? res.data.promoterList[key].avatar : "/static/assets/images/tx.jpg";
                    html += "                    <div class=\"weui-cells card-box\">\n" +
                        "                        <div class=\"weui-cell\">\n" +
                        "                            <div class=\"weui-cell__hd mr10\">\n" +
                        "                                <img src=\""+img+"\" class=\"tximg\">\n" +
                        "                            </div>\n" +
                        "                            <div class=\"weui-cell__bd\">\n" +
                        "                                <div class=\"weui-flex \" style=\"justify-content: space-between\">\n" +
                        "                                    <div class=\"fs26 fw600\">"+res.data.promoterList[key].nickname+"</div>\n" +
                        "                                    <div class=\"fs26 text-gray\">ID："+money+"</div>\n" +
                        "                                </div>\n" +
                        "                                <div class=\" fs26 fw600 mt10\" style=\"justify-content: space-between\">\n" +
                        "                                    <div>手机："+mobile+"</div>\n" +
                        "                                    <div>注册时间："+res.data.promoterList[key].register_time+"</div>\n" +
                        "                                </div>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                    </div>"
                }
                length = res.data.promoterList.length;
                if(length < 10){
                    html += "<div class=\"fs24 text-muted mt30 tc\">已经到底啦~</div>";
                }else{
                    page = page + 1;
                }
                if(time == 1) {
                    if (length == 0) {
                        html = "<div class=\"empeyOrder\" style=\"width: 100%;text-align: center;\">\n" +
                            "                <img style=\"width: 100%;\" src=\"/static/mobile/default/images/emptyData.png\" alt=\"\">\n" +
                            "                <span class=\"fs24 text-muted tc mt30\">暂无记录</span>\n" +
                            "            </div>";

                    }
                }
                $('.week').text(res.data.addUserWeek);
                $('.month').text(res.data.addUserMonth);
                $('#tab1').html(html);

            }
        })
    }
    function dateTrans(date) {
        let _date = new Date(parseInt(date));
        let y = _date.getFullYear();
        let m = _date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        let d = _date.getDate();
        d = d < 10 ? ('0' + d) : d;
        let h = _date.getHours();
        h = h < 10 ? ('0' + h) : h;
        let minute = _date.getMinutes();
        let second = _date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute; second = second < 10 ? ('0' + second) : second;
        // console.log( y + '-' + m + '-' + d + ' ' + '　' + h + ':' + minute + ':' + second)
        let dates = y + '/' + m + '/' + d;

        return dates;
    }
</script>
<script>

</script>
</body>
</html>